package main

import "fmt"

func main() {
	a := Dog{}
	foo(a)
	bar(a)
}
func foo(a AnimalRunner) {
	a.Speak()
	a.run()
}

// 泛型约束需用 interface{} 包裹多个接口
func bar[T interface {
	Animal
	RunInterface
}](a T) {
	a.run()
	a.Speak()
}

type Animal interface {
	Speak()
}
type RunInterface interface {
	run()
}
type Dog struct{}

func (d Dog) Speak() {
	fmt.Println("Dog is Woof!")
}
func (d Dog) run() {
	fmt.Println("Dog is running!")

}

// 接口聚合
type AnimalRunner interface {
	Animal
	RunInterface
}
